package models

import (
	"gorm.io/gorm"
	"time"
)

// Email 邮件结构体
type Email struct {
	gorm.Model
	MessageID    string    `gorm:"uniqueIndex;size:255"`
	To           string    `gorm:"type:text"` // 逗号分隔的收件人
	Cc           string    `gorm:"type:text"` // 逗号分隔的抄送
	Bcc          string    `gorm:"type:text"` // 逗号分隔的密送
	Subject      string    `gorm:"type:varchar(255)"`
	Body         string    `gorm:"type:text"`
	ContentType  string    `gorm:"type:varchar(50)"` // text/plain or text/html
	Attempts     int       // 发送尝试次数
	LastAttempt  time.Time // 上次尝试发送的时间
	Status       string    `gorm:"type:varchar(20)"` // pending, success, failed
	ErrorMessage string    `gorm:"type:text"`
	CallbackURL  string    `gorm:"type:varchar(255)"` // 回调URL
}

func (e *Email) TableName() string {
	return "tb_plugin_email"
}

type DataSourceInfo struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	UserName string `json:"userName"`
	Password string `json:"password"`
	From     string `json:"from"`
	SSl      bool   `json:"ssl"`
	SSLPORT  int    `json:"sslport"`
}
